package pro.shushi.pamirs.hr.api.model.eam;

import pro.shushi.pamirs.boot.base.ux.annotation.field.UxWidget;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxDetail;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxForm;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxTableSearch;
import pro.shushi.pamirs.hr.api.enums.BooleanConstantEnum;
import pro.shushi.pamirs.hr.api.enums.eam.LocStatEnum;
import pro.shushi.pamirs.hr.api.enums.eam.MtoolSrcTypeEnum;
import pro.shushi.pamirs.hr.api.enums.eam.MtoolStatEnum;
import pro.shushi.pamirs.hr.api.model.eam.common.AbstractOrgBaseModel;
import pro.shushi.pamirs.meta.annotation.Field;
import pro.shushi.pamirs.meta.annotation.Model;
import pro.shushi.pamirs.meta.annotation.Prop;

import java.util.Date;

// 模型中UX开头的注解(UxForm/UxTable/UxDetail等)可以不用写，都可在设计器中进行可视化配置; 代码里面写这些注解是为了默认页面的交互
@UxForm(grid = 3)
@UxDetail(grid = 3)
@Model.model(BsMtool.MODEL_MODEL)
@Model(displayName = "工装信息维护",labelFields = "mtoolCode")
@Model.Advanced(table="bs_mtool",unique = {"orgCode,mtoolCode"})
public class BsMtool extends AbstractOrgBaseModel {

    public static final String MODEL_MODEL = "hr.simple.bsMtool";

    @UxTableSearch.FieldWidget(@UxWidget())
    @Field(displayName = "组织编码", required = true)
    private String orgCode;

    @UxTableSearch.FieldWidget(@UxWidget())
    @Field(displayName = "工装编码", required = true)
    public String mtoolCode;

    @UxTableSearch.FieldWidget(@UxWidget())
    @Field(displayName = "工装名称", required = true)
    public String mtoolName;

    // ---------- 工装型号 ----------------------
    @UxTableSearch.FieldWidget(@UxWidget())
    // 清除工装型号，自动清除mmdName
    @UxForm.FieldWidget(@UxWidget(config = {@Prop(name = "clearFields", value = "mmdName")}))
    @Field.many2one
    @Field.Relation(relationFields = {"orgCode","mmdCode"}, referenceFields = {"orgCode","mmdCode"})
    @Field(displayName = "工装型号", required = true)
    private BsMtoolMd bsMtoolMd;

    @Field.String
    @Field(displayName = "工装型号编码", invisible = true)
    private String mmdCode;

    @Field.String
    @Field.Related(related = {"bsMtoolMd", "mmdName"})
    @UxForm.FieldWidget(@UxWidget(readonly = "true"))
    @Field(displayName = "工装型号名称")
    private String mmdName;

    // ---------- 工装型号 ----------------------
    @Field(displayName = "出厂序列号")
    public String mfDevSn;

    @Field(displayName = "资产编码")
    public String assetCode;

    @Field.Enum(size='4')
    @Field(displayName = "位置状态", required = true,defaultValue = "1")
    public LocStatEnum locStat;

    @Field.Enum(size='4')
    @Field(displayName = "状态", required = true,defaultValue = "0")
    public MtoolStatEnum mtoolStat;

    @Field(displayName = "仓库编码")
    public String storeCode;

    @Field(displayName = "储位编码")
    public String storelocCode;

    @Field.Date
    @Field(displayName = "报废时间")
    public Date scrapTime;

    @Field.Date
    @Field(displayName = "最后保养日期")
    public Date lastUkDate;

    @Field.Integer
    @Field(displayName = "保养后使用次数", required = true,defaultValue = "0")
    public Integer ukUsedTimes;

    @Field.Integer
    @Field(displayName = "总使用次数", required = true,defaultValue = "0")
    public Integer totUsedTimes;

    @Field(displayName = "设备编码")
    public String devCode;

    @Field.Date
    @Field(displayName = "内部校准时间")
    public Date iadjDate;

    @Field.Date
    @Field(displayName = "外部校准时间")
    public Date oadjDate;

    @Field.Enum(size='1')
    @Field(displayName = "带病作业",  defaultValue = "n")
    public BooleanConstantEnum isSick;

    @Field.Enum(size='4')
    @Field(displayName = "来源", required = true)
    public MtoolSrcTypeEnum mtoolSrcType;

    @Field.Enum(size='1')
    @Field(displayName = "启用", required = true, defaultValue = "y")
    public BooleanConstantEnum isValid;

    @Field.Text
    @Field(displayName = "备注")
    private String remark;

    @UxForm.FieldWidget(@UxWidget(group = "采购信息"))
    @UxDetail.FieldWidget(@UxWidget(group = "采购信息"))
    @Field(displayName = "供应商编码")
    public String supCode;

    @Field(displayName = "制造商编码")
    public String mfCode;

    @Field.Date
    @Field(displayName = "生产日期")
    public Date mfDate;

    @Field.Date
    @Field(displayName = "购买日期")
    public Date purDate;

    @Field(displayName = "采购单编码")
    public String poCode;

    @Field.Date
    @Field(displayName = "入库日期")
    public Date inDate;

    @UxForm.FieldWidget(@UxWidget(group = "当前使用状态"))
    @UxDetail.FieldWidget(@UxWidget(group = "当前使用状态"))
    @Field(displayName = "产线编码")
    public String plCode;

    @Field(displayName = "工序编码")
    public String wpCode;


}
